/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    queue<TreeNode*> cur;
    vector<int> array;
    vector<int> levelOrder(TreeNode* root) {
        if(array.size()) array.clear();
        if(root) cur.push(root);
        while(cur.size()){
            array.push_back(cur.front()->val);
            if(cur.front()->left) cur.push(cur.front()->left);
            if(cur.front()->right)cur.push(cur.front()->right);
            cur.pop();
        }
        return array;
    }
};